<template>
    <!-- <el-form :model="RoleForm" :rules="rules" label-width="80px"> -->
    <el-form :model="RoleForm" 
    label-width="80px" :rules="rules" ref="formName ">
        <el-form-item label="角色名称">
            <el-input v-model="RoleForm.RoleName" :readonly=true></el-input>
        </el-form-item>
        <!-- <el-form-item label="角色描述" prop="product"> -->
        <el-form-item label="角色描述" >
            <el-input v-model="RoleForm.RoleDesc" :readonly=true></el-input>
        </el-form-item>

        <el-form-item label="角色权限id"  prop="RoleRightId">
            <el-input v-model="RoleForm.RoleRightId"></el-input>
        </el-form-item>
        <el-form-item label="菜单节点id"  prop="NodeId">
            <el-input v-model="RoleForm.NodeId" ></el-input>
        </el-form-item>


        <el-form-item>
            <el-button type="primary" @click="onSubmit(RoleForm.RoleId,RoleForm.NodeId,RoleForm.RoleRightId)">确定</el-button>
            <el-button type="primary" @click="onClose">关闭</el-button>
        </el-form-item>
    </el-form>
</template>

<script>
import {mockRoleManInfo} from '../../../api/roleMan.js'
import { ElMessage } from 'element-plus'
export default {

    props: ['RoleInfo',"roleMans"],
    emits: ['close'],
    data() {
        return {
            roleMan:[],
            RoleForm: 
                {RoleName: '',
                RoleDesc: '',
                RoleRightId: null,//角色权限id
                RoleId: null,   ////角色id
                NodeId: null,//菜单节点id}
            },
            rules: {
                RoleRightId: [
                    {
                        required: true,
                        message: '请输入角色名称',
                        trigger: 'blur',
                    },
                ],
                NodeId: [
                    {
                        required: true,
                        message: '请输入角色名称',
                        trigger: 'blur',
                    },
                ],
            },
        }
    },
    created() {
        this.RoleForm = { ...this.RoleInfo }
        this.roleMan=this.roleMans
    },
    mounted(){
        // this.start()
      
    },
    methods: {
       
        async onSubmit(RoleId,NodeId,RoleRightId) {
            // console.log("提交信息",RoleId,NodeId,RoleRightId)

            if(NodeId&&RoleRightId){
                        this.onClose()

                // const data=await mockRoleManInfo(RoleId,NodeId,RoleRightId)
                // console.log("addRoleMan",data)

                // const { resultCode,resultInfo } = data
                // console.log('resultInfo ',resultInfo )
                // if (resultCode === 1) {
                //     ElMessage({
                //         message: '设置权限成功!',
                //         type: 'success',
                //     })
                //     this.onClose()
                // }else{
                //     ElMessage({
                //         message: '设置权限失败!',
                //         type: 'error',
                //     })
                // }
                //    this.roleMan.forEach((obj) => {
                //     if (obj.RoleId === RoleId) {
                //         obj['RoleRightId'] = RoleRightId
                //         obj['NodeId'] = NodeId
                //         console.log("this.RoleForm",this.roleMan)
                //         this.onClose()
                //     }
                // })

            }else{
                ElMessage({
                        message: '内容不能为空!',
                        type: 'error',
                    })
            }
        },
      
        onClose() {
            this.$emit('close')
        },

    },
}
</script>

<style lang="less" scoped>
.avatar {
    width: 150px;
    height: 150px;
    display: block;
}
</style>
